/**
 * Last Modified by Teddy Karam on 2-6-2012 4:26 PM
 *
 */
package com.redteam.data.beans;

import com.redteam.interfaces.Customer;
import java.io.Serializable;
import java.sql.Date;

/**
 * A java bean for Students
 * @author Anthony Ferrari
 */
public final class Student extends Pilot implements Customer, Serializable {

    private Instructor preferredInstructor;
    private HouseAccount account;
    private static final long serialVersionUID = 1L;


    /**
     * Student full constructor
     * @param id
     * @param firstName
     * @param middleName
     * @param lastName
     * @param street
     * @param city
     * @param state
     * @param zipCode
     * @param email
     * @param fBOId
     * @param birthdate
     * @param homePhone
     * @param cellPhone
     * @param workPhone
     * @param gender
     * @param flightHours
     * @param endorse
     * @param type
     * @param username
     * @param password
     * @param preferredInstructor
     */
    public Student(long id, String firstName, String middleName, String lastName, String street, String city, String state, String zipCode, String email, long fBOId, Date birthdate, String homePhone, String cellPhone, String workPhone, String gender, int flightHours, String type, String username, String password) {
        super(id, firstName, middleName, lastName, street, city, state, zipCode, email, fBOId, birthdate, homePhone, cellPhone, workPhone, gender, flightHours, type, username, password);
        this.setPreferredInstructor(new Instructor());
    }

    /**
     * Default constructor
     */
    public Student() {
        super();
        this.setPreferredInstructor(new Instructor());
    }

    /**
     * Returns the preferred instructor
     * @return preferredInstructor
     */
    public Instructor getPreferredInstructor() {
        return preferredInstructor;
    }

    /**
     * Sets the preferred instructor
     * @param preferedInstructor
     */
    public void setPreferredInstructor(Instructor preferedInstructor) {
        this.preferredInstructor = preferedInstructor;
    }

    /**
     * @inheritDoc
     */
    @Override
    public HouseAccount getHouseAccount() {

        return account;
    }

    /**
     * @inheritDoc
     */
    @Override
    public void setHouseAccount(HouseAccount account) {
        this.account = account;
    }

    /**
     * @inheritDoc
     */
    @Override
    public double makePayment(Payment payment) {
        double amount = account.getBalance() - payment.getPaymentAmount();
        account.setBalance(amount);

        return amount;
    }

    /**
     * @inheritDoc
     */
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Student other = (Student) obj;
        if (this.preferredInstructor != other.preferredInstructor && (this.preferredInstructor == null || !this.preferredInstructor.equals(other.preferredInstructor))) {
            return false;
        }
        if (this.account != other.account && (this.account == null || !this.account.equals(other.account))) {
            return false;
        }
        return true;
    }

    /**
     * @inheritDoc
     */
    @Override
    public int hashCode() {
        int hash = 7;
        hash = 79 * hash + (this.preferredInstructor != null ? this.preferredInstructor.hashCode() : 0);
        hash = 79 * hash + (this.account != null ? this.account.hashCode() : 0);
        return hash;
    }
}
